<%
	com.googlecode.jwsm.security.User user = null;
	if (request.getAttribute("login") != Boolean.FALSE) {
		if (request.getAttribute("login") == Boolean.TRUE) {
			user = com.googlecode.jwsm.JWSMSecurity.getUser(request, response, false);
		} else {
			user = com.googlecode.jwsm.JWSMSecurity.getUser(request, response, true);
		}
		if ("true".equals(request.getParameter("logout"))) {
			com.googlecode.jwsm.JWSMSecurity.logout(request, response);
		}
		if ((request.getAttribute("login") != Boolean.TRUE) && (user == null)) {
			return;
		}
	}

	String threadName = request.getRequestURI();
	if (threadName == null) threadName = "WebInterface";
	if (threadName.indexOf('/') > -1) {
		threadName = threadName.substring(threadName.lastIndexOf('/') + 1);
	}
	Thread.currentThread().setName(threadName);
	if (!com.googlecode.jwsm.Uploader.initted) response.sendRedirect("Uploader");
	
	String[] types = ServiceManager.getInstance().getServiceReturnTypes();%>
<%@ page import="com.googlecode.jwsm.*" %>
<html>
<head>
<title>Java Web Service Manager</title>
<%@ include file="css.jsp" %>
<style type="text/css"><%@ include file="scripts/calendar/calendar-system.css" %></style>
<script language="JavaScript" src="scripts/drop_down.js"></script>
<script language="JavaScript" src="HelpServlet?resource=help.js"></script>
<script language="JavaScript" src="scripts/scripts.jsp"></script>
<script language="JavaScript" src="scripts/sorttable.js"></script>
<script language="JavaScript" src="HelpServlet?resource=ajax.js"></script>
<script language="JavaScript" src="scripts/calendar/calendar.js"></script>
<script language="JavaScript" src="scripts/calendar/calendar-en.js"></script>
<script language="JavaScript" src="scripts/calendar/calendar-setup.js"></script>
</head>
<body onload="register(document.getElementById('helpComponent'), document.getElementById('helpContainer'), false);">
<div id="helpComponent" style="visibility: hidden; position: absolute;">
	<table cellpadding="0" cellspacing="0" border="0">
		<tr valign="top" height="7">
			<td align="left"><img src="images/help_top_left.png"/></td>
			<td bgcolor="<%= CSSDefaults.BG_COLOR %>"><img src="spacer.png" width="1" height="7"/></td>
			<td align="right"><img src="images/help_top_right.png"/></td>
		</tr>
		<tr bgcolor="<%= CSSDefaults.BG_COLOR %>">
			<td>&#160;</td>
			<td id="helpContainer" class="menu" style="text-align: justify;"></td>
			<td>&#160;</td>
		</tr>
		<tr valign="bottom" height="7">
			<td align="left"><img src="images/help_bottom_left.png"/></td>
			<td bgcolor="<%= CSSDefaults.BG_COLOR %>"><img src="spacer.png" width="1" height="7"/></td>
			<td align="right"><img src="images/help_bottom_right.png"/></td>
		</tr>
	</table>
</div>
<table width="100%" cellpadding="5" cellspacing="0" border="0" bgcolor="<%= CSSDefaults.BG_COLOR %>">
<tr>
	<td style="font-size: 16pt; font-weight: bold; color: white;" colspan="2" id="JWSM">
		Java Web Service Manager <sub><i><%= Uploader.VERSION %></i></sub>
	</td>
	<td align="right" valign="bottom" style="font-size: 10pt; color: white;" colspan="2">
	<% if (user != null) { %>
		<b id="MenuLoggedIn">Logged in as:</b> <span id="MenuLoggedIn"><%= user.getUsername().toLowerCase() %></span> | <a class="menu" href="?logout=true" id="MenuLogOut">Log out</a>
	<% }  else { %>
		<b id="MenuNotLoggedIn">Not logged in</b>
	<% } %>
	&#160;&#160;&#160;
	<a href="#" onclick="toggleHelp();"><img src="images/help.png" border="0"/></a>
	</td>
</tr>
<tr bgcolor="#000000;">
	<% if (user != null) { %>
	<td align="center"><a href="index.jsp" class="menu" id="MenuServiceList">Service List</a></td>
	<td align="center">
		<% if (user.hasPrivilege("jwsm.service_deploy")) { %>
			<a href="service.jsp" class="menu" id="MenuDeployService">Deploy Service</a>
		<% } else { %>
			<span style="color: gray;" id="MenuDeployService">Deploy Service</span>
		<% } %>
	</td>
	<td align="center">
		<% if (user.hasPrivilege("jwsm.settings_manage")) { %>
			<a href="configuration.jsp" class="menu" id="MenuSettings">Settings</a></td>
		<% } else { %>
			<span style="color: gray;" id="MenuSettings">Settings</span>
		<% } %>
	<td align="center"><a href="logs.jsp" class="menu" id="MenuLogs">Logs</a></td>
	<% } else { %>
	<td colspan="4">&#160;</td>
	<% } %>
</tr>
</table>
<br/><br/>
<center>